﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Net;
using System.ServiceModel.DomainServices.Client;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Navigation;
using DiagnosticCenter.Web;

namespace DiagnosticCenter.View
{
    public partial class viewOperatorTestEdit : Page
    {
        public int currentTestID {get; set;}
        public ObservableCollection<TestDifficulty> Difficulty = new ObservableCollection<TestDifficulty>();
        
        public viewOperatorTestEdit()
        {
            InitializeComponent();

            TestDifficulty item = new TestDifficulty();
            item.SectionName = "Уровень 1";
            item.QuestionNumbers = "1;2;3;10;11;12";
            item.SectionCount = 4;
            item.SectionRating = 2;
            Difficulty.Add(item);
            
            item = new TestDifficulty();
            item.SectionName = "Уровень 2";
            item.QuestionNumbers = "4;5;6;7;8;9";
            item.SectionCount = 2;
            item.SectionRating = 4;
            Difficulty.Add(item);

            gridDifficulty.ItemsSource = Difficulty;

        }

        // Executes when the user navigates to this page.
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            currentTestID = 5;
        }

        private void DomainDataContext_LoadedData(object sender, LoadedDataEventArgs e)
        {
            if (e.HasError)
            {
                MessageBox.Show(e.Error.ToString(), "Load Error", MessageBoxButton.OK);
                e.MarkErrorAsHandled();
            }
        }

        private void comboRatingMode_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {

            if (comboRatingMode == null) return;
            switch (comboRatingMode.SelectedIndex)
            {
                case 0:
                    gridRatingSimple.Visibility = Visibility.Visible;
                    gridRatingSection.Visibility = Visibility.Collapsed;
                    break;
                case 1:
                    gridRatingSection.Visibility = Visibility.Visible;
                    gridRatingSimple.Visibility = Visibility.Collapsed;
                    break;
            }
        }
    }

    public class TestDifficulty
    {
        public string SectionName { get; set; }
        public string QuestionNumbers { get; set; }
        public int SectionCount { get; set; }
        public int SectionRating { get; set; }
    }
}
//TODO: FIX: Разобраться с привязками
//TODO: NEW: Возможность добавлять/удалять и изменять топики
//TODO: NEW: Возможность добавлять/удалять и изменять вопросы